package com.xvyy.tingshu.account.rpc;

import com.xvyy.tingshu.account.service.UserAccountService;
import com.xvyy.tingshu.common.result.Result;
import com.xvyy.tingshu.model.account.RechargeInfo;
import com.xvyy.tingshu.vo.account.AccountLockResultVo;
import com.xvyy.tingshu.vo.account.AccountLockVo;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName: UserAccountRpcController
 * Package: com.xvyy.tingshu.account.rpc
 *
 * @Description:
 * @Author: xvyy
 * @Create: 2025/2/11 - 13:06
 * @Version: v1.0
 */
@RestController
@RequestMapping("/api/rpc/userAccount")
public class UserAccountRpcController {

    @Autowired
    private UserAccountService userAccountService;

    @PostMapping("/checkAndLockAccount")
    @Operation(summary = "检查账户余额并锁定")
    Result<AccountLockResultVo> checkAndLockAccount(@RequestBody AccountLockVo accountLockVo) {
        return userAccountService.checkAndLockAccount(accountLockVo);
    }

    @PostMapping("/getRechargeInfoByOrder")
    @Operation(summary = "根据订单编号查询充值业务")
    Result<RechargeInfo> getRechargeInfoByOrder(@PathVariable(value = "orderNo") String orderNo){
        RechargeInfo rechargeInfo = userAccountService.getRechargeInfoByOrder(orderNo);
        return Result.ok(rechargeInfo);
    }
}
